#!/bin/bash

#set -xv


if [ $# != 3 ] ; then 
echo "USAGE: $0 path original_content modified_content" 
echo "eg.替换IP地址: myreplace . 192.168.7.237 192.168.66.128" 
exit 1;
fi 

echo "path:$1"
echo "original content:$2"
echo "modified_content:$3"

#全局替换当前路径下的指定类型文件中的内容
#find $1 -name "*.[h|c]" -o -name "*.cpp" | xargs sed  -i  's/192.168.68.128/192.168.7.237/g'
# find $1 -name "*.[h|c]" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.xml" -o -name "*cc" | xargs sed  -i  "s/$2/$3/g"
# find $1 -name "*.[h|c]" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.xml" -o -name "*cc" | xargs sed  -i  "s/\<$2\>/$3/g"
# find $1 -name "*.*" | xargs sed  -i  "s/$2/$3/g"
# find $1 -name "*.[h|c]" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.xml" -o -name "*.cc" -o -name "*.go" -o -name "*.js" -o -name "*.html" -o -name "*.toml" | xargs sed  -i  "s/\<$2\>/$3/g"
find $1 -name "*.[h|c]" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.xml" -o -name "*.cc" -o -name "*.go" -o -name "*.js" -o -name "*.json" -o -name "*.html" -o -name "*.toml" | xargs sed  -i  "s/$2/$3/g"
